function pressHeadImg(photoPicUrl, canvasId, maxSizeWidth, maxSizeHeight, thisObj) {
    return new Promise((resolve, reject) => {
        wx.getImageInfo({
            src: photoPicUrl,
            success: function(res) {
                console.log('图片信息res', res)
                    // ---------利用canvas压缩图片--------------
                var canvasWidth = res.width; // 图片原始长宽
                var canvasHeight = res.height;
                var ratio = 2;
                // 微信头像宽高是 132 ×132
                while (canvasWidth > maxSizeWidth || canvasHeight > maxSizeHeight) { // 保证宽高在528之内
                    console.log('进来while了===')
                    canvasWidth = Math.trunc(res.width / ratio)
                    canvasHeight = Math.trunc(res.height / ratio)
                    ratio++;
                }
                console.log('循环后的', canvasWidth, canvasHeight)
                    // ----------绘制图形并取出图片路径--------------
                var ctx = uni.createCanvasContext(canvasId, thisObj)
                ctx.width = canvasWidth
                ctx.height = canvasHeight
				console.log('循环后的000')
                ctx.drawImage(res.path, 0, 0, canvasWidth, canvasHeight)
				console.log('循环后的001')
                ctx.draw(false, () => {
					console.log('循环后的002')
                    setTimeout(() => {
						console.log('循环后的003')
                        uni.canvasToTempFilePath({
                            x: 0,
                            y: 0,
                            width: canvasWidth,
                            height: canvasHeight,
                            canvasId,
                            fileType: 'jpg',
                            success: function(res) {
                                let url = res.tempFilePath
                                console.log('url==', url)
                                resolve(res.tempFilePath)
                            },
                            fail: (err) => {
                                console.log('图片导出失败，请重试', err);
                                resolve(false)
                            }
                        }, thisObj)
                    }, 20)
                })

            }
        })
    })
}
// 昵称 字符计算
function nickNameCharacterCount(nickNameStr) {
    let characterLength = 0
        // 输入的是空白的
    if (!(nickNameStr.trim())) characterLength = 0
    if (nickNameStr.trim()) {
        // 一个汉字2个字符、一个表情符是4个字符
        let reg = /[\u4E00-\u9FA5]/ // 匹配一个汉字
        for (let [index, val] of Array.from(nickNameStr).entries()) {
            if (val.codePointAt(0) > 0xFFFF) { // 含有表情符 是4个字符 长度加2
                characterLength += 4
            } else if (reg.test(val)) { // 是汉字
                characterLength += 2
            } else {
                characterLength += 1
            }
        }
    }

    return characterLength
}
export {
    pressHeadImg,
    nickNameCharacterCount
}